Skip to content

Fix CLIProxyApi model normalization and cross-provider pricing in Claude Code (#2393) - #2415

Closed
Yuxin-Qiao wants to merge 3 commits into
steipete:mainfrom
Yuxin-Qiao:fix/issue-2393-cli-proxy-pricing
Closed

Fix CLIProxyApi model normalization and cross-provider pricing in Claude Code (#2393)#2415
Yuxin-Qiao wants to merge 3 commits into
steipete:mainfrom
Yuxin-Qiao:fix/issue-2393-cli-proxy-pricing

Conversation

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor

Fixes #2393

Summary

  • When using CLIProxyApi or custom proxies in Claude Code, non-Claude models or proxy model names (e.g. cli-proxy-gpt-5.4, cli-proxy-gpt4o) logged in Claude Code resulted in costUSD = nil (unpriced / unknown model cost).
  • Added proxy prefix stripping (cli-proxy-, proxy-, openai/, anthropic/, etc.) and model alias normalization in CostUsagePricing.
  • Enabled cross-provider pricing fallback in claudeCostUSD so non-Claude models logged under Claude Code can resolve prices across OpenAI / models.dev catalogs.
  • Added regression tests in CostUsageScannerClaudeRegressionTests.swift.

Verification

  • Ran swift test --filter "issue 2393" (passed).
  • Ran make check (passed).

@clawsweeper

clawsweeper Bot commented Jul 23, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Fix CLIProxyApi model normalization and cross-provider pricing in Claude Code (#2393) This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e31d068c69

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

inputTokens: totalPromptTokens,
cachedInputTokens: cacheReadInputTokens,
outputTokens: outputTokens,
cacheWriteInputTokens: 0,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve cache-write tokens when pricing proxy OpenAI logs

When Claude Code logs a non-Claude model with cache_creation_input_tokens, totalPromptTokens already includes those cache-write tokens, but this call passes cacheWriteInputTokens: 0. codexCostUSD then treats the writes as ordinary uncached input, so proxy OpenAI models with cache-write tariffs (for example GPT-5.6 built-ins or models.dev cache_write rates) get incorrect costs; pass cacheCreationInputTokens as the cache-write subset instead.

Useful? React with 👍 / 👎.

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Closing in favor of #2413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Token cost estimate is tied only to the harness, not to the model.

1 participant